﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TwKarma.Web.Service.DTO
{
    public class TwitterUser
    {
        public int Id;
        public string ScreenName;
		public string ProfileImageUrl;
        public int Score;

		public static TwitterUser Get(int id)
		{
			return Map(TwKarma.Data.Entity.TwitterUser.Get(id));			
		}

		public static TwitterUser Get(string screenname)
		{
			return Map(TwKarma.Data.Entity.TwitterUser.Get(screenname));
		}

		private static TwitterUser Map(TwKarma.Data.Entity.TwitterUser user)
		{
			if (user == null)
				return null;

			return new TwitterUser()
			{
				Id = user.TwitterId,
				Score = user.Score + user.SumKarmaVotes,
				ScreenName = user.ScreenName,
				ProfileImageUrl = user.ProfileImageUrl
			};			
		}
    }
}